CHARTS
Photo by Tommy Lisbin on Unsplash
As a single mum you’ll discover inner strengths and capabilities you never knew you had…
— Emma-Louise Smith
url_root <- "https://raw.githubusercontent.com/UN-AVT/kamino-source/main/sources/0-shared/data/"
url_file <- "gender-pay-gap/uk-gender-pay-gap.csv"
url <- paste0(url_root, url_file)
df <- read.csv(url, header = TRUE, stringsAsFactors = FALSE) # read text file
df
df_wrangle <- df
df_wrangle$Type <- as.factor(df_wrangle$Type)
head(df_wrangle)
theme_opts <- theme(
text = element_text(family = "inconsolata"),
plot.title = element_text(color = "black", size = 14, face = "bold"),
plot.subtitle = element_text(color = "black", size = 12),
plot.caption = element_text(color = "#555555", size = 10, hjust = 1.0, vjust = 1.0),
axis.title.x = element_blank(),
# axis.title.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_text(size = 12, hjust = 1.0, vjust = 0.5),
panel.border = element_blank(),
panel.background = element_blank(),
#panel.grid.minor = element_blank(), # remove minor gridlines
panel.grid.major.x = element_blank(), # remove x (vertical) gridlines
panel.grid.minor.x = element_blank(), # remove x (vertical) gridlines
legend.title = element_blank(), # remove legend title
legend.text = element_text(color = "black", size = 10),
legend.position='bottom',
plot.margin = unit(c(0.5, 0.25, 0.5, 0.5), "in")
)
offset <- 500
v1<-ggplot(df_wrangle) +
geom_segment( aes(x = Women_average_annual_salary, xend = Men_average_annual_salary, y = Occupation, yend = Occupation), lineend = "butt", linejoin = "round", size=1.0, color="black" ) +
geom_point( aes(x = Women_average_annual_salary, y = Occupation), shape = 21, size = 3, fill = "#5AC085", color = "#5AC085", alpha = 0.9) +
geom_text( aes(x = Women_average_annual_salary - (ifelse(Pay_gap > 0, offset, -offset)), y = Occupation, label=Women_average_annual_salary),
size=4, color="black",
hjust = ifelse(df_wrangle$Pay_gap > 0, 1.0, 0.0),
vjust = 0.5, family = "inconsolata" ) +
geom_point( aes(x = Men_average_annual_salary, y = Occupation), shape = 21, size = 3, fill = "#474B52", color = "#474B52", alpha = 0.9) +
geom_text( aes(x = Men_average_annual_salary + (ifelse(Pay_gap > 0, offset, -offset)), y = Occupation, label=Men_average_annual_salary),
size=4, color="black",
hjust = ifelse(df_wrangle$Pay_gap > 0, 0.0, 1.0),
vjust = 0.5, family = "inconsolata" ) +
scale_x_continuous() +
coord_cartesian(clip = "off") +
facet_wrap(~Type, scales = "free", ncol = 1) +
labs(title = "GENDER PAY GAP",
subtitle = "UK, by salary and job category",
caption = "Source: UK Office for National Statistics",
x = NULL,
y = NULL) +
theme_minimal() +
theme_opts
girafe(ggobj = v1, width_svg = 16, height_svg = 15,
options = list(opts_sizing(rescale = TRUE, width = 0.95)))